package com.cn.longdistancebusstation.httpapi;


import com.cn.longdistancebusstation.annotation.OrderStatus;
import com.cn.longdistancebusstation.model.ConfirmResult;
import com.cn.longdistancebusstation.model.Contacter;
import com.cn.longdistancebusstation.model.Coupons;
import com.cn.longdistancebusstation.model.DatePrice;
import com.cn.longdistancebusstation.model.CancleOrder;
import com.cn.longdistancebusstation.model.Identification;
import com.cn.longdistancebusstation.model.Integration;
import com.cn.longdistancebusstation.model.ListResult;
import com.cn.longdistancebusstation.model.ListResultII;
import com.cn.longdistancebusstation.model.ListResultIII;
import com.cn.longdistancebusstation.model.ListResultV;
import com.cn.longdistancebusstation.model.News;
import com.cn.longdistancebusstation.model.OrderInfo;
import com.cn.longdistancebusstation.model.OrderResult;
import com.cn.longdistancebusstation.model.Privilege;
import com.cn.longdistancebusstation.model.QRCodeResult;
import com.cn.longdistancebusstation.model.Result;
import com.cn.longdistancebusstation.model.Scenic;
import com.cn.longdistancebusstation.model.ScenicDetails;
import com.cn.longdistancebusstation.model.ScenicOrder;
import com.cn.longdistancebusstation.model.ScenicOrderDetails;
import com.cn.longdistancebusstation.model.ScenicOrderList;
import com.cn.longdistancebusstation.model.SelectTicketOrder;
import com.cn.longdistancebusstation.model.SubmitPftOrder;
import com.cn.longdistancebusstation.model.Ticket;
import com.cn.longdistancebusstation.model.TicketInfo;
import com.cn.longdistancebusstation.model.UserInfo;
import com.cn.longdistancebusstation.model.Version;


import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * Created by mal on 2018/1/21.
 */

public interface HttpService {
    //通用
    @FormUrlEncoded
    @POST("{path}")
    Call<String> request(@Path(value = "path", encoded = true) String requestPath, @FieldMap Map<String, String> params);

    //注册
    @FormUrlEncoded
    @POST("loginAndroid/addTelephoneUser.action")
    Call<Result<UserInfo>> register(@Field("entry.telephone")String username,
                            @Field("entry.password")String password);

    //手机号是否已注册过
    @FormUrlEncoded
    @POST("loginAndroid/checkUser.action")
    Call<Result> checkPhoneIsExist(@Field("entry.telephone")String phone);

    //登录
    @FormUrlEncoded
    @POST("loginAndroid/getLogin.action")
    Call<Result<UserInfo>> login(@Field("searchParam.telephone")String username,
                                 @Field("searchParam.password")String password);

    //重置密码
    @FormUrlEncoded
    @POST("loginAndroid/resetPassword.action")
    Call<Result> resetPassword(@Field("searchParam.telephone")String username,
                                     @Field("searchParam.password")String password);

    //修改密码
    @FormUrlEncoded
    @POST("loginAndroid/modifyPwd.action")
    Call<Result> editPassword(@Field("searchParam.telephone")String username,
                                    @Field("searchParam.oldPwd")String oldPassword,
                                    @Field("searchParam.newPwd")String newPassword);

    //首页轮播图
    @GET("homeCarouselAndroid/list.action?page=1&rows=5")
    Call<ListResult<News>> getNews();

    //联系人
    //添加常用联系人
    @FormUrlEncoded
    @POST("useContactAndroid/addUseContact.action")
    Call<Result> addContacter(@Field("entry.userName")String name,
                                    @Field("entry.idNum")String cardNo,
                                    @Field("entry.telephone")String telephone,
                                    @Field("entry.userType")String type,
                                    @Field("entry.loginId")String userID);

    //获取常用联系人
    @GET("useContactAndroid/list.action?page=1&rows=200")
    Call<ListResult<Contacter>> getCommonContacts(@Query("searchParam.loginId") String userID);

    //修改常用联系人
    @FormUrlEncoded
    @POST("useContactAndroid/modify.action")
    Call<Result> editContacter(@Field("entry.id")String contacterID,
                                     @Field("entry.userName")String contacterName,
                                     @Field("entry.idNum")String cardNo,
                                     @Field("entry.telephone")String telephone,
                                     @Field("entry.userType")String contacterType);

    //删除常用联系人
    @FormUrlEncoded
    @POST("useContactAndroid/remove.action")
    Call<Result> deleteContacter(@Field("idStr")String ids);

    //订票
    //确认订单
    @FormUrlEncoded
    @POST("bookTicketAndroid/addBookTicket.action")
    Call<ConfirmResult> confirmOrder(@FieldMap  Map<String, String> params);

    //取消订单(多个座位号用英文逗号分隔)
    @FormUrlEncoded
    @POST("bookTicketAndroid/cancelTicket.action?searchParam.modiMode=1")
    Call<OrderResult> cancelOrder(@Field("searchParam.bookOrderNo")String orderNo,
                                  @Field("searchParam.ticketDate")String outingDate,
                                  @Field("searchParam.ticketSeatNo")String seatNo
                             );

    //退票
    @FormUrlEncoded
    @POST("bookTicketAndroid/refundTicket.action")
    Call<Result> refundTicket(@Field("searchParam.rBookID")String orderNo,
                              @Field("searchParam.rSeatNo")String seatNo,
                              @Field("searchParam.rBliidDate")String outingDate,
                              @Field("searchParam.loginId")String loginId
                              );

    //我的订单列表
    @FormUrlEncoded
    @POST("bookTicketAndroid/list.action")
    Call<ListResult<OrderInfo>> getOrderList(@Field("searchParam.ticketDate")String outingDate,
                                             @Field("searchParam.loginId")String userID,
                                             @Field("page")int page,
                                             @Field("rows")int countPerPage,
                                             @Field("searchParam.status")@OrderStatus int status);

    //订单详情
    @FormUrlEncoded
    @POST("bookTicketAndroid/gainBookDetail.action")
    Call<ListResultII<TicketInfo>> getOrderDetail(@Field("searchParam.bookID")String orderNo,
                                                  @Field("searchParam.searchDate")String outingDate);

    //获取订单加密信息
    @FormUrlEncoded
    @POST("alipayAndroidAction/encryptAndSign.action")
    Call<Result<String>> getEncryptOrderInfo(@Field("searchParam.bookNum")String orderNo,
                                             @Field("searchParam.totalAmout")String totalAmount,
                                             @Field("searchParam.ticketDate")String sendDat,
                                             @Field("searchParam.loginId")String loginId);
    //支付宝支付


    //设置
    //修改手机号
    @FormUrlEncoded
    @POST("loginAndroid/modifyTelephone.action")
    Call<Result> editMobilePhone(@Field("searchParam.oldTelephone") String oldPhone,
                                 @Field("searchParam.newTelephone") String newPhone);

    //版本更新
    @GET("loginAndroid/updateNewVersion.action?searchParam.versionCode=sdbusstation_Android")
    Call<Result<Version>> getVersionInfo(@Query("searchParam.versionNum") int versionCode);

    //获取积分
    @FormUrlEncoded
    @POST("loginAndroid/gainIntegral.action")
    Call<Result<Integration>> getIntegration(@Field("entry.id") String loginId);

    //获取优惠券
    @FormUrlEncoded
    @POST("loginAndroid/gainCoupons.action")
    Call<ListResultII<Coupons>> getCoupons(@Field("entry.id") String loginId);

    @FormUrlEncoded
    @POST("loginAndroid/gainCoupons.action")
    Call<ListResultII<Privilege>> getPrivileges(@Field("entry.id") String userID);

    //景点列表
    @FormUrlEncoded
    @POST("mobile/scenery/queryScenicSpotList.action")
    Call<ListResult<Scenic>> getSenicList(@Field("searchParam.n") int n,
                                             @Field("searchParam.m") int m);

    //门票列表
    @FormUrlEncoded
    @POST("mobile/scenery/queryTickets.action")
    Call<ListResult<Ticket>> getTicket(@Field("searchParam.n") String scenicId,
                                       @Field("searchParam.m") String ticketId);
    //景点简介
    @FormUrlEncoded
    @POST("mobile/scenery/queryScenicSportInfo.action")
    Call<ListResultIII<ScenicDetails>> getScenicDetails(@Field("searchParam.scenicSportInfoId") String scenicId);
    //获取日期
    @FormUrlEncoded
    @POST("mobile/scenery/queryStorageUsingDate.action")
    Call<ListResult<DatePrice>> getDatePrice(@Field("searchParam.aid")String aId,
                                                @Field("searchParam.pid")String pId,
                                                @Field("searchParam.startDate") String startDate,
                                                @Field("searchParam.endDate")String endDate);
    //提交门票订单
    @FormUrlEncoded
    @POST("mobile/scenery/submitOrder.action")
    Call<ListResultV<ScenicOrder>> getScenicOrder(@FieldMap Map<String, String> params);

    //身份验证
    @FormUrlEncoded
    @POST("mobile/scenery/checkPersonID.action")
    Call<ListResultIII<Identification>> getIdentification(@Field("searchParam.personId")String cardNo);

    //取消订单
    @FormUrlEncoded
    @POST("mobile/scenery/cancelOrder.action")
    Call<Result> getCancleOrder(@Field("searchParam.orderId")String orderId);

    //查询景点门票订单
    @FormUrlEncoded
    @POST("mobile/scenery/queryOrder.action")
    Call<ListResultIII<SelectTicketOrder>> getTicketOrder(@Field("searchParam.pftOrdernum")String pftOrdernum,
                                                          @Field("searchParam.remoteOrdernum")String remoteOrdernum);

    //查询景点订单列表
    @FormUrlEncoded
    @POST("mobile/scenery/queryMyOrders.action")
    Call<ListResult<ScenicOrderList>> getScenicOrderList(@Field("searchParam.userId")String userId);


    //获取景点门票加密加签
    @FormUrlEncoded
    @POST("alipayAndroidAction/encryptAndSign.action")
    Call<Result<String>> getScenicEncryptOrderInfo(@Field("searchParam.jingqu")String scenic,
                                             @Field("searchParam.totalAmount")String totalAmount,
                                             @Field("searchParam.subject")String scenicSituation,
                                             @Field("searchParam.pftOrdernum")String pftOrdernum,
                                                   @Field("searchParam.remoteOrdernum")String remotenum);

    //根据订单号查询订单详细信息
    @FormUrlEncoded
    @POST("mobile/scenery/queryOrderDetail.action")
    Call<ListResultV<ScenicOrderDetails>> getScenicOrderDetails(@Field("searchParam.orderId")String scenicId);

    //退票
    @FormUrlEncoded
    @POST("mobile/scenery/refundTicket.action")
    Call<Result> refund(@Field("searchParam.ptfOrderId")String pftId,
                        @Field("searchParam.orderId")String orderId,
                        @Field("searchParam.realNum")String realNum);

    //票付通订单提交
    @FormUrlEncoded
    @POST("mobile/scenery/submitPftOrder.action")
    Call<ListResultIII<SubmitPftOrder>> submitPftOrder(@FieldMap Map<String, String> params);

    //获取二维码图片
    @GET
    Call<String> getQRCode(@Url String reqeustURL);



}
